package com.qujia.markert.controller;

import com.qujia.common.core.controller.BaseController;
import com.qujia.common.core.domain.AjaxResult;
import com.qujia.common.core.domain.ResultData;
import com.qujia.common.core.page.TableDataInfo;
import com.qujia.markert.domain.req.SaleActivityOrderQueryReq;
import com.qujia.markert.domain.vo.SaleActivityOrderSumVO;
import com.qujia.markert.service.ISaleActivityOrderService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Arrays;

/**
 * @date 2023/12/21
 */
@RestController
@RequestMapping(value = "/saleActivityOrder")
public class SaleActivityOrderController extends BaseController {

    @Resource
    private ISaleActivityOrderService saleActivityOrderService;

    /**
     * 刪除/list
     * @author BEJSON
     * @date 2023/12/21
     **/
    @GetMapping("/delete")
    public ResultData delete(Long[] ids){
        saleActivityOrderService.removeByIds(Arrays.asList(ids));
        return ResultData.success();
    }

    /**
     * 查询 分页查询
     * @author BEJSON
     * @date 2023/12/21
     **/
    @GetMapping("/list")
    public TableDataInfo pageList(SaleActivityOrderQueryReq queryReq) {
        startPage();
        return getDataTable(saleActivityOrderService.queryList(queryReq));
    }

    @GetMapping("refund")
    public ResultData refund(@RequestParam Long id){
        saleActivityOrderService.refund(id);
        return ResultData.success();
    }

    @GetMapping("sum")
    public ResultData<SaleActivityOrderSumVO> saleActivityOrderSum(SaleActivityOrderQueryReq queryReq){
        return ResultData.success(saleActivityOrderService.saleActivityOrderSum(queryReq));
    }

    @GetMapping("export")
    public AjaxResult export(SaleActivityOrderQueryReq queryReq){
        return saleActivityOrderService.export(queryReq);
    }

}
